<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>作用域</title>
</head>
<body>
<script>

// function foo(m, n) {
//   var a = 1;
//   let b = 2;
//   function bar() {
//     function inner() {
//       return a + b + m + n;
//     }
//     console.dir(inner)
//   }
//   console.dir(bar)
//   bar()
// }

const a = 20;

function test() {
  const b = a + 10;
  var m = 20;
  const x = 10
  const y = 20

  function innerTest() {
    console.log(x, y)
    const c = 10 + m;
    console.dir(innerTest)

    function bar() {
      console.log(c)
      console.dir(bar)
    }
    return bar;
  }

  return innerTest();
}

var foo = test();
foo()

// 查询栈空间的大小
function mc() {
  var a = 1
  var b = 2
  const c = 10
  try {
    return 1 + mc()
  } catch(e) {
    return 1
  }
}

</script>
</body>
</html>